package com.hhwy.frame.controller;


import com.alibaba.fastjson.JSONArray;
import com.hhwy.frame.server.IndexService;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;import java.util.List;
import java.util.Map;

@Controller
public class indexController
{
    Logger log = LoggerFactory.getLogger(indexController.class);
    private String hello;
    @Autowired
    IndexService indexService;
    @RequestMapping(value = "/",method = RequestMethod.GET)
    public String hello(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());
        System.out.println("测试我问问");
        return "admins/index";
    }




    @RequestMapping(value = "/demo/welcome2.html",method = RequestMethod.GET)
    public String welcome2(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/welcome2";
    }
    @RequestMapping(value = "/demo/btn.html",method = RequestMethod.GET)
    public String btn(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/btn";
    }
    @RequestMapping(value = "/demo/form.html",method = RequestMethod.GET)
    public String form(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/form";
    }
    @RequestMapping(value = "/demo/table.html",method = RequestMethod.GET)
    public String table(Model model){

        List<Map> list = indexService.getList();
        model.addAttribute("name",list);
        //map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/table";
    }
    @RequestMapping(value = "/demo/tab-card.html",method = RequestMethod.GET)
    public String tab_card(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/tab-card";
    }
    @RequestMapping(value = "/demo/progress-bar.html",method = RequestMethod.GET)
    public String progress_bar(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/progress-bar";
    }
    @RequestMapping(value = "/demo/folding-panel.html",method = RequestMethod.GET)
    public String folding_panel(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/folding-panel";
    }
    @RequestMapping(value = "/demo/auxiliar.html",method = RequestMethod.GET)
    public String auxiliar(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/auxiliar";
    }
    @RequestMapping(value = "/demo/login.html",method = RequestMethod.GET)
    public String login(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/login";
    }
    @RequestMapping(value = "/demo/map.html",method = RequestMethod.GET)
    public String map(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/map";
    }
    @RequestMapping(value = "/demo/add-edit.html",method = RequestMethod.GET)
    public String add_edit(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/add-edit";
    }

    @RequestMapping(value = "/demo/data-table.html",method = RequestMethod.GET)
    public String data_table(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/data-table";
    }

    @RequestMapping(value = "/demo/tree-table.html",method = RequestMethod.GET)
    public String tree_table(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/tree-table";
    }
    @RequestMapping(value = "/demo/404.html",method = RequestMethod.GET)
    public String page_404(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/404";
    }
    @RequestMapping(value = "/demo/tips.html",method = RequestMethod.GET)
    public String tips(Map<String,Object> map){
        List<Map> list = indexService.getList();
        for (int i = 0;i<list.size();i++){
            log.info(list.get(i).toString());
        }
        map.put("name", JSONArray.toJSON(list).toString());

        return "admins/demo/tips";
    }


}
